package fragments.shopadapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.travel.R;

import java.util.List;

import shopbean.GvOneBena;

/**
 * Created by Administrator on 2016/10/23.
 */
public class ShopGriOneItemAdapter extends BaseAdapter {
    private Context context;
    private List<GvOneBena.DataBean.LineBean> list;

    public ShopGriOneItemAdapter(Context context, List<GvOneBena.DataBean.LineBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view==null){
            view= LayoutInflater.from(context).inflate(R.layout.shop_gv_oneitem,null);
            holder=new ViewHolder();
            holder.shop_gvOne_item_iv= (ImageView) view.findViewById(R.id.shop_gvOne_item_iv);
            holder.shop_gvOne_item_title= (TextView) view.findViewById(R.id.shop_gvOne_item_title);
            holder.shop_gvOne_item_type= (TextView) view.findViewById(R.id.shop_gvOne_item_type);
            holder.shop_gvOne_item_days= (TextView) view.findViewById(R.id.shop_gvOne_item_days);
            holder.shop_gvOne_item_content= (TextView) view.findViewById(R.id.shop_gvOne_item_content);
            holder.shop_gvOne_item_hot= (TextView) view.findViewById(R.id.shop_gvOne_item_hot);
            holder.shop_gvOne_item_price= (TextView) view.findViewById(R.id.shop_gvOne_item_price);
            holder.textView= (TextView) view.findViewById(R.id.textView);
            view.setTag(holder);
        }else{
            holder= (ViewHolder) view.getTag();
        }
        Glide.with(context).load(list.get(i).getThumbPath()).into(holder.shop_gvOne_item_iv);
        holder.shop_gvOne_item_type.setText(list.get(i).getTravelType());
        holder.shop_gvOne_item_title.setText(list.get(i).getTitleApp());
        holder.shop_gvOne_item_content.setText(list.get(i).getTitle());
        String hot=list.get(i).getHotelStar();
        if ("0".equals(hot)){
            holder.shop_gvOne_item_hot.setVisibility(View.GONE);
            holder.textView.setVisibility(View.GONE);
        }else {
            holder.shop_gvOne_item_hot.setText(hot);
        }
        String day=list.get(i).getDaysShow();
        if ("0天".equals(day)){
            holder.shop_gvOne_item_days.setVisibility(View.GONE);
        }else {
            holder.shop_gvOne_item_days.setText(day);
        }
        holder.shop_gvOne_item_price.setText(list.get(i).getPrice());
        return view;
    }
    static  class ViewHolder{
        ImageView shop_gvOne_item_iv;
        TextView shop_gvOne_item_type,shop_gvOne_item_title,shop_gvOne_item_days,shop_gvOne_item_content,shop_gvOne_item_hot,shop_gvOne_item_price,textView;
    }
}
